package my.graduation.controller.common;

import my.graduation.dto.*;
import my.graduation.entity.ExaminationRecord;
import my.graduation.entity.RegistrationRecord;
import my.graduation.result.Result;
import my.graduation.service.ExaminationRecordService;
import my.graduation.vo.AlertPaidVO;
import my.graduation.vo.DataVO;
import my.graduation.vo.RegistrationRecordVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: RavenLyn
 * @Date: 2025-02-26
 */
@RestController
@RequestMapping
public class ExaminationRecordController {

    @Autowired
    private ExaminationRecordService examRecordService;

    /**
     * 医生给患者开检查单
     * @param dto
     * @return
     */
    @PostMapping("/doctor/exam_record/pre")
    public Result docPrescribe(@RequestBody PrescribeDto dto){
        return examRecordService.addRecord(dto);
    }

    /**
     * 患者查询未预约检查记录 (patientId + status == unpaid)
     * @param dto
     * @return
     */
    @PostMapping("/patient/exam_record/list_unpaid")
    public Result<List<ExaminationRecord>> patGetUnpaidList(@RequestBody ExamRecordDto dto){
        return examRecordService.patGetUnpaidlist(dto);
    }

    /**
     * 患者查询所有检查预约记录 (patientId)
     * @param dto
     * @return
     */
    @PostMapping("/patient/exam_record/list")
    public Result<List<ExaminationRecord>> patGetAllList(@RequestBody ExamRecordDto dto){
        return examRecordService.patGetAlllist(dto);
    }

    /**
     * 获取当前的检查预约记录
     * @param dto
     * @return
     */
    @PostMapping("/patient/exam_record")
    public Result<ExaminationRecord> getExamCurrentRecord (@RequestBody ExamRecordDto dto){
        return examRecordService.getExamCurrentRecord(dto);
    }


//    /**
//     * 医生获取当天检查队列
//     * @param dto
//     * @return
//     */
//    @PostMapping("/doctor/exam_record")
//    public Result<List<RegistrationRecordVO>> getListByDoctorId(@RequestBody RegRecordDto dto){
//        return examRecordService.getListByDoctorId(dto);
//    }

    /**
     * 医生修改患者检查状态-完成
     * @param dto
     * @return
     */
    @PutMapping("/doctor/exam_record")
    public Result checkFinished(@RequestBody ExamRecordDto dto){
        return examRecordService.checkFinished(dto);
    }

    /**
     * 管理员获取挂号检查 - 数据分析
     * @param dto
     * @return
     */
    @PostMapping("/admin/exam_data")
    public Result<List<DataVO>> getRegData(@RequestBody DataDto dto){
        return examRecordService.getRegData(dto);
    }

    /**
     * 管理员获取未就诊检查记录
     * @return
     */
    @GetMapping("/admin/exam_paid")
    public Result<List<AlertPaidVO>> getPaidData(){
        return examRecordService.getPaidData();
    }
}
